<?php
include dirname(dirname(__FILE__)).'/admin-verify.php';
include dirname(__FILE__).'/functions.php';
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
		<title>财务管理</title>
		<?php include dirname(dirname(dirname(__FILE__))).'/include/common-header.php' ?>
		<script type="text/javascript">
		$(document).ready(function (){

			$("#form_date").change(function(event) {
				var form_date=$(this).val();
				$.post('ajax/get-goods-form.php', {val: form_date}, function(data1, textStatus, xhr) {
							if (data1!="no") {

								
								var result=data1.split("*")
								var goods_content=result[0];
								var class_content=result[1];
								 goods_content = eval('(' + goods_content + ')');
								 class_content= eval('(' + class_content + ')');
								 var content="";
								 $i=0;
								 var cnt;
								 $.each(class_content, function(index, val) {
								 	cnt=val.goods_num;
								 	if (cnt!=0){
								 	content=content+'<tr>'+
								 					'<td rowspan="'+val.goods_num+'">'+val.class+'</td>'+
								 					'<td>'+goods_content[$i].name+'</td>'+
								 					'<td>'+goods_content[$i].price+'</td>'+
								 					'<td>'+goods_content[$i].number+'</td>'+
								 					'<td>'+goods_content[$i].count+'</td>'+
								 					'<td>'+(goods_content[$i].count*goods_content[$i].number)+'</td>'+
								 					'<td>'+(goods_content[$i].count*goods_content[$i].price)+'</td>'+
								 					'</tr>';
								 					
								 		cnt--;
								 		$i++;
								 	}
								 		while(cnt!=0){

								 			content=content+'<tr>'+
								 					'<td>'+goods_content[$i].name+'</td>'+
								 					'<td>'+goods_content[$i].price+'</td>'+
								 					'<td>'+goods_content[$i].number+'</td>'+
								 					'<td>'+goods_content[$i].count+'</td>'+
								 					'<td>'+(goods_content[$i].count*goods_content[$i].number)+'</td>'+
								 					'<td>'+(goods_content[$i].count*goods_content[$i].price)+'</td>'+
								 					'</tr>';
								 					
								 		cnt--;
								 		$i++;

								 		}
								 	
								 });

								 $("#goods-form-show").empty();
								 $("#goods-form-show").append(content);
								



						}else{
							alert("查询出错");
							location.reload();
						}




				});
			});

		});
		
		</script>

</head>
<body>

	<div class="container" style="margin-top: 30px;">
	<div class="form-group">
		<label for="form_date" class="col-sm-2 control-label">日期</label>
		<div class="col-sm-6">
		<select style="width:60%" name="form_date" id="form_date" class="form-control">
			<?php
			$ret=getFormDate();
			while ($row=mysql_fetch_array($ret)) {
				if($row["form_date"]!=null){
					echo '<option value="'.$row["form_date"].'">'.$row["form_date"].'</option>';
				}
			}
			
			?>
		</select>
		 </div>
		 </div>
	 </div>


	 <div class="row" style="margin-bottom: 50px;"></div>

	<div class="container" >
	<table class="table table-bordered" >
      <thead>
        <tr>
          <th>类型</th>
          <th>名称</th>
          <th>价格/箱</th>
          <th>件数/箱</th>
          <th>进货/箱</th>
          <th>数量</th>
          <th>小结</th>
        </tr>
      </thead>
      <tbody id="goods-form-show">



     </tbody>
    </table>
	</div>
	 
</body>
</html>